package com.hanamaki.DataStruct;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author hanamaki
 * @version 1.0
 * @date 2021/6/29 14:02
 */
public class ListAndMapTest {
    public static void main(String[] args) {

//        初始化  ArrayList 容器
//        ArrayList 线程不安全集合
        List<Map<String, String>> list = new ArrayList<>();

//        初始化 map
        Map<String, String> map = new HashMap<>();
        Map<String, String> map1 = new HashMap<>();
        Map<String, String> map2 = new HashMap<>();

        map.put("1", "9");
        map.put("2", "8");
        map.put("3", "7");
        map1.put("4", "6");
        map1.put("5", "5");
        map1.put("6", "4");
        map2.put("7", "3");
        map2.put("8", "2");
        map2.put("9", "1");

        list.add(map);
        list.add(map1);
        list.add(map2);


        System.out.println(list);


//        遍历 list 容器
        for (Map<String, String> stringMap : list) {
            for (String k : stringMap.keySet()) {
                System.out.println("k=" + k + ":v=" + stringMap.get(k));
            }
        }
    }
}
